package jdesktop.appbar;

public enum Edge
{
    LEFT,
    RIGHT,
    TOP,
    BOTTOM;

    /**
     * The number of edges. 
     */
    public static final int EDGE_COUNT = 4;

    public boolean isOrigin()
    {
        return this==LEFT || this==TOP;
    }

    /**
     * For an edge, the orientation defines the direction that connects this edge and it's opposite edge.
     * @return
     */
    public Orientation getOrientation()
    {
        return (this==LEFT || this==RIGHT) ? Orientation.HORIZONTAL: Orientation.VERTICAL;
    }

    public Edge getOppositeEdge()
    {
        switch (this)
        {
            case LEFT: return RIGHT;
            case RIGHT: return LEFT;
            case TOP: return BOTTOM;
            case BOTTOM: return TOP;
            default:
                return this;
        }
    }

    /**
     * Fetches the next edge that is
     * @return
     */
    public Edge getAdjacentEdgeCW()
    {
        switch (this)
        {
            case LEFT: return TOP;
            case TOP: return RIGHT;
            case RIGHT: return BOTTOM;
            case BOTTOM: return LEFT;
            default:
                return this;
        }
    }

    public Edge getAdjacentEdgeCCW()
    {
        switch (this)
        {
            case LEFT: return BOTTOM;
            case BOTTOM: return RIGHT;
            case RIGHT: return TOP;
            case TOP: return LEFT;
            default:
                return this;
        }
    }


}
